using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using emp.BLL.SysManage;
using emp.Model.SysManage;


public partial class systemmanage_user_user_province : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int userid=0;
        if (Request["UserID"] != null)
        {
            hiddne_user_id.Value = Request["UserID"].ToString();
            userid = Convert.ToInt32(Request["UserID"].ToString());
        }
        if (Request["cur_page"] != null)
        {

            hidden_cur_page.Value = Request["cur_page"].ToString();
            gvquestlist.PageIndex=Convert.ToInt32( Request["cur_page"].ToString());
        }
        if (Request["MenuID"] != null)
        {
            hidden_menuid.Value = Request["MenuID"].ToString();
        }
        User user = new User();
        IList list=user.getUserList(int.Parse(hiddne_user_id.Value));
        if (list.Count>0)
        {
            UserInfo myUserInfo = (UserInfo)list[0];
            Label1.Text= myUserInfo.UserName;
        }
        inital(userid);
    }
    protected void gvquestlist_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {

        GridView theGrid = sender as GridView;
        int newPageIndex = 0;



        if (-2 == e.NewPageIndex)
        {
            TextBox txtNewPageIndex = null;
            GridViewRow pagerRow = theGrid.BottomPagerRow;
            if (null != pagerRow)
            {
                txtNewPageIndex = pagerRow.FindControl("txtNewPageIndex") as TextBox;
            }
            if (null != txtNewPageIndex)
            {
                newPageIndex = int.Parse(txtNewPageIndex.Text) - 1;
            }
        }
        else
        {
            newPageIndex = e.NewPageIndex;
        }

        newPageIndex = newPageIndex < 0 ? 0 : newPageIndex;
        newPageIndex = newPageIndex >= theGrid.PageCount ? theGrid.PageCount - 1 : newPageIndex;
        theGrid.PageIndex = newPageIndex;
        inital(Convert.ToInt32(hiddne_user_id.Value));
    }
    private void inital(int uid)
    {
        User user = new User();
        IList list = user.getUserProviceList(uid);
        this.gvquestlist.DataSource = list;
        this.gvquestlist.DataBind();
    }

    protected void newadd_Click(object sender, EventArgs e)
    {
        Response.Redirect("province_list.aspx?UserID=" + hiddne_user_id.Value + "&cur_page=" + hidden_cur_page.Value+"&MenuID=" + hidden_menuid .Value);

    }
    protected void back_Click(object sender, EventArgs e)
    {
        Response.Redirect("user_list.aspx?MenuID=" + hidden_menuid .Value+ "&cur_page=" + hidden_cur_page.Value);
    }
}
